<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>表单</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="./layui/src/css/layui.css">
    <script src="./layui/src/layui.js"></script>
    <script src="./js/JQ.js"></script>

  <style>
  body{padding: 10px;}
  </style>
</head>
<body>

<hr>

<form id="form" class="layui-form layui-form-pane1" action="/user/teacher_register" lay-filter="first">
  <div class="layui-form-item">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-block">
      <input type="text" id="name" name="name" class="layui-input" >
    </div>
  </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-block">
          <input type="number" id="phone" name="phone" class="layui-input" >
        </div>
    </div>

  <div class="layui-form-item">
    <label class="layui-form-label">教师账号</label>
    <div class="layui-input-block">
      <input type="text" id="username" name="username" class="layui-input" >
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-block">
      <input type="password" id="password" name="password" class="layui-input" >
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-input-block">
      <a onclick="sbm();" class="layui-btn">立即提交</a>
      <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
    </div>
  </div>
</form>

<br><br><br>

<script>
  function sbm() {
      if(document.getElementById("name").value.length == 0){
          alert("姓名不能为空");
          return;
      }
      if(document.getElementById("phone").value.length == 0){
          alert("电话不能为空");
          return;
      }
      if(document.getElementById("username").value.length == 0){
          alert("账号不能为空");
          return;
      }
      if(document.getElementById("password").value.length == 0){
          alert("密码不能为空");
          return;
      }
      document.getElementById("form").submit();
  }

</script>
</body>
</html>
